/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework
 * Version 2.10
 * 
 * Data Connection Event Arguments Class
 *      Provides an event arguments definition for data-specific connection-related events.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
using System;
using System.Data;
using System.Data.Common;

namespace Adaptive.Foundation.Data
{
    /// <summary>
    /// Provides an event arguments definition for connection-related events.
    /// </summary>
    public class ConnectionEventArgs : EventArgs
    {
        /*--------------------------------------------------------------------------------
         * Private Member Declarations
		 *------------------------------------------------------------------------------*/
        #region Private Member Declarations
        /// <summary>
        /// Connection instance.
        /// </summary>
        private IDbConnection _connection;
        /// <summary>
        /// Success or failure falg.
        /// </summary>
        private bool _success;
        #endregion

        /*--------------------------------------------------------------------------------
         * Constructor / Dispose / Destructor Methods
		 *------------------------------------------------------------------------------*/
        #region Constructor / Dispose / Destructor Methods
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <remarks>
        /// This is the default constructor.
        /// </remarks>
        /// <param name="connection">
        /// The new connection instance.
        /// </param>
        public ConnectionEventArgs(IDbConnection connection) : base()
        {
            _connection = connection;
            _success = true;
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <remarks>
        /// This is the default constructor.
        /// </remarks>
        /// <param name="connection">
        /// The new connection instance.
        /// </param>
        /// <param name="success">
        /// A value indicating whether the related operation was a success.
        /// </param>
        public ConnectionEventArgs(IDbConnection connection, bool success)
            : base()
        {
            _connection = connection;
            _success = success;
        }
        /// <summary>
        /// Class destructor.
        /// </summary>
        ~ConnectionEventArgs()
        {
            _connection = null;
        }
        #endregion

        /*--------------------------------------------------------------------------------
	     * Public Properties
		 *------------------------------------------------------------------------------*/
        #region Public Properties
        /// <summary>
        /// Gets the reference to the database connection object.
        /// </summary>
        /// <value>
        /// A valid <see cref="IDbConnection"/> connection object, or <b>null</b> if an operation failed.
        /// </value>
        public IDbConnection Connection
        {
            get { return _connection; }
        }
        /// <summary>
        /// Gets a value indicating whether the last operation was successful.
        /// </summary>
        /// <value>
        /// <b>true</b> if the operation that caused the event was successful; otherwise, <b>false</b>.
        /// </value>
        public bool Success
        {
            get { return _success; }
        }
        #endregion

    }
}